<?php
namespace App\Http\Controllers;
class ProxyController extends Controller
{
    // 通用微信页面跳转
    public function index()
    {
	//支持的url
	$allow_paths = array(
    	    '/proxy' => 'proxy',
	);
	//解析url
	$url = parse_url($_SERVER['REQUEST_URI']);
	if(empty($allow_paths[$url['path']])){
    	    header("HTTP/1.0 404 Not Found");
    	    exit;
	}
	$url = isset($_GET['url'])?$_GET['url']:'';
	$code = isset($_GET['code'])?$_GET['code']:'';
	$state = isset($_GET['state'])?$_GET['state']:'';
	if(strpos($url, '?')){
    	    $next = $url.'&code='.$code.'&state='.$state;
	}else{
      	    $next = $url.'?code='.$code.'&state='.$state;
        }
	header('Location: '.$next);    
    }

}
